package com.example.gameapplication.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

import com.example.gameapplication.R;
import com.example.gameapplication.database.DataUtils;
import com.example.gameapplication.dialog.DialogUtils;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import butterknife.Unbinder;

public class WelComeActivity extends AppCompatActivity {

    @BindView(R.id.tv_endless)
    TextView tvEndless;
    @BindView(R.id.tv_breakthrough)
    TextView tvBreakthrough;
    @BindView(R.id.tv_record)
    TextView tvRecord;
    @BindView(R.id.tv_finish)
    TextView tvFinish;
    @BindView(R.id.tv_window)
    TextView tvWindow;
    private Unbinder bind;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_wel_come);
        bind = ButterKnife.bind(this);

    }

    @Override
    protected void onResume() {
        super.onResume();
        DataUtils.cleanData();
    }

    @OnClick({R.id.tv_endless, R.id.tv_breakthrough, R.id.tv_record, R.id.tv_window, R.id.tv_finish})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.tv_endless:
                startActivity(MainActivity.class);
                DataUtils.setIsPlaying(true);
                DataUtils.setIsCustom(false);
                break;
            case R.id.tv_breakthrough:
                startActivity(MainActivity.class);
                DataUtils.setIsPlaying(true);
                DataUtils.setIsCustom(true);
                break;
            case R.id.tv_record:
                startActivity(RecordActivity.class);
                break;
            case R.id.tv_window:
                startActivity(WindowActivity.class);
                DataUtils.setIsPlaying(true);
                DataUtils.setIsCustom(false);
                break;
            case R.id.tv_finish:
//                finish();
                DialogUtils.showControlDialog(this);
                break;
        }
    }

    private void startActivity(Class activity) {
        startActivity(new Intent(this, activity));
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        if (bind != null) bind.unbind();
    }
    //单独使用的方法
    /**
     * 初始化FloatWindow
     */
//    private void initFloatWindow() {
//
//        View inflate = LayoutInflater.from(this).inflate(R.layout.activity_main, null);
//        FloatWindow
//                .with(getApplicationContext())
//                .setView(inflate)
//                .setWidth(Screen.width,0.7f)
//                .setHeight(Screen.height,0.7f)
//                .setX(Screen.width,0.8f)
//                .setY(Screen.height,0.6f)
//                .setMoveType(MoveType.slide)
//                .setMoveStyle(500,new BounceInterpolator())
////                .setFilter(true,MainActivity.class)
//                .setDesktopShow(true)
//                .setTag("FloatWindow")
//                .build();
////        inflate.setOnClickListener(new View.OnClickListener() {
////            @Override
////            public void onClick(View view) {
////
////            }
////        });
////        inflate.setOnLongClickListener(new View.OnLongClickListener() {
////            @Override
////            public boolean onLongClick(View v) {//必须返回 true，不然拖拽的时候也会触发点击事件
////                return true;
////            }
////        });
//        FloatWindow.get("FloatWindow").show();
//    }
}
